package com.atsugon.demo02.service.implement;

import com.atsugon.demo02.bean.Alert;
import com.atsugon.demo02.bean.AlertCount;
import com.atsugon.demo02.mapper.AlertMapper;
import com.atsugon.demo02.service.AlertService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AlertServiceImp extends ServiceImpl<AlertMapper, Alert> implements AlertService {
    @Autowired
    private AlertMapper alertMapper;

    @Override
    public Integer DayselectByDate(String date) {
        return alertMapper.DayselectByDate(date);
    }

    @Override
    public Integer MonthselectByDate(String date) {
        return alertMapper.MonthselectByDate(date);
    }

    @Override
    public Integer WeekselectByDate(String date) {
        return alertMapper.WeekselectByDate(date);
    }

    @Override
    public Integer YearselectByDate(String date) {
        return alertMapper.YearselectByDate(date);
    }

    @Override
    public String InsertById(String rowname, Integer id) {
        if (alertMapper.InsertById(rowname,id)!=1){
            return "插入失败";
        }
        return "插入成功";
    }

    @Override
    public String DeleteById(Integer id) {
        if(alertMapper.DeleteById(id)!=1){
            return "删除失败";
        }
        return "删除成功";
    }

    @Override
    public String UpdateStatus(Integer id,Integer status) {
        if(alertMapper.UpdateStatus(id,status)!=1){
            return "更新失败";
        }
        return "更新成功";
    }


    //按天获取报警次数
    @Override
    public List<AlertCount> xmlDayselectByDate(){
        return alertMapper.xmlDayselectByDate();
    };
    @Override
    public List<AlertCount> xmlDayselectByDateLimitPage(Long pfrom,Long pto){
        return alertMapper.xmlDayselectByDateLimitPage(pfrom,pto);
    };
    //按周获取报警次数
    @Override
    public List<AlertCount>  xmlDayselectByWeek(){
        return alertMapper.xmlDayselectByWeek();
    };
    @Override
    public List<AlertCount>  xmlDayselectByWeekLimitPage(Long pfrom,Long pto){
        return alertMapper.xmlDayselectByWeekLimitPage(pfrom,pto);
    };
    //按月获取报警次数
    @Override
    public List<AlertCount>  xmlDayselectByMonth(){
        return alertMapper.xmlDayselectByMonth();
    };
    @Override
    public List<AlertCount>  xmlDayselectByMonthLimitPage(Long pfrom,Long pto){
        return alertMapper.xmlDayselectByMonthLimitPage(pfrom,pto);
    };
    //按年获取报警次数
    @Override
    public List<AlertCount>  xmlDayselectByYear(){
        return alertMapper.xmlDayselectByYear();
    };
    @Override
    public List<AlertCount>  xmlDayselectByYearLimitPage(Long pfrom,Long pto){
        return alertMapper.xmlDayselectByYearLimitPage(pfrom,pto);
    };

}
